﻿using System;
using System.IO;

namespace PicasaWebAlbumsDownloader
{
    public static class Extensions
    {
        public static void CopyTo(this Stream input, Stream output)
        {
            var buffer = new byte[8 * 1024];
            int len;
            while ((len = input.Read(buffer, 0, buffer.Length)) > 0)
            {
                output.Write(buffer, 0, len);
            }
        }

        public static string FixFileName(this string source)
        {
            if (source == null)
            {
                return source;
            }
            Array.ForEach(Path.GetInvalidFileNameChars(), c => source = source.Replace(c, '_'));
            return source;
        }
    }
}